/*
 * Copyright © 2011 SenseForce.com.
 * The Software shall be used for Good, not Evil.
 */

package com.jai2me.uikit;

import com.jai2me.foundation.*;

import javax.microedition.lcdui.*;

/**
 * The JAIView class defines a rectangular area on the screen and the interfaces for managing the content in that area.
 * At runtime, a view object handles the rendering of any content in its area and also handles any interactions with that content.
 * The JAIView class itself provides basic behavior for filling its rectangular area with a background color.
 * @author jcccn
 * @site http://www.senseforce.com/
 */
public class JAIView implements JAIFoundationInterface {
    /*
     * The receiver’s alpha value.
     */
    private int alpha = 255;

    /*
     * A Boolean value that determines whether the receiver automatically resizes its subviews when its bounds change.
     */
    private boolean autoresizeSubviews = true;

    /*
     * An integer mask that determines how the receiver resizes itself when its superview’s bounds change.
     */
    private int autoresizingMask = JAIUIDef.JAIViewAutoresizingNone;

    //TODO to set the default background color
    private JAIColor backgroundColor = new JAIColor();

    //TODO
    private JAIRect bounds = new JAIRect();

    private JAIPoint center = new JAIPoint();

    /*
     * Determines whether the view could be focused.
     */
    private boolean focusable = true;

    /*
     * The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.
     */
    private JAIRect frame = new JAIRect();

    private boolean hidden = false;

    /*
     * The view’s Graphics used for rendering.
     */
    private Graphics graphics = null;

    /*
     * The receiver’s immediate subviews.
     */
    private JAIArray subviews = new JAIArray();

    /*
     * The receiver’s superview, or null if it has none.
     */
    private JAIView superview = null;

    /*
     * An integer that you can use to identify view objects in your application.
     */
    private int tag = 0;

    /*
     * A boolean value that determines whether user events are ignored and removed from the event queue.
     */
    private boolean userInteractionEnabled = true;

    public Object init() {
        return this;
    }

    public String description() {
        StringBuffer descriptionString = new StringBuffer();
        //TODO To finish the infomation
        descriptionString.append("frame:");
        return descriptionString.toString();
    }

    public void release() {
        backgroundColor = null;
        bounds = null;
        center = null;
        frame = null;
        graphics = null;
        //TODO Before subviews is released,release it's items
        subviews = null;
        superview = null;
    }
}
